package com.lcifn.springmvc.controller;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.lcifn.springmvc.bean.User;

@Controller
@RequestMapping("user")
public class UserController {
	
	@RequestMapping("get")
	public ModelAndView list(){
		ModelAndView mav = new ModelAndView();
		mav.setViewName("user/list");
		
		List<User> users = new ArrayList<>();
		users.add(new User("zhangesan", 20));
		users.add(new User("lisi", 25));
		
		mav.addObject("users", users);
		return mav;
	}
	
	public static void main(String[] args) {
		List<Long> list = new ArrayList<>();
		list = list.stream().filter(l -> l == 1).collect(Collectors.toList());
		System.out.println(list);
		Map<Long, Long> map = list.stream().collect(Collectors.toMap(Function.identity(), Function.identity()));
		System.out.println(map);
	}
}
